// components/roombottom/roombottom.js
import {reqListMerchandiseByAnchorId} from '../../api/liveroom'

Component({

  /**
   * 组件的属性列表
   */
  properties: {
    anchorId:{
      type:String,
      value:''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    show: false,
    goods:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {

    showMiniMall(){
      this.setData({ show: true });
      this.showMerchandise()
    },

    closeMiniMall(){
      this.setData({ show: false });
    },

    async showMerchandise(){
      const param={
        anchorId:this.properties.anchorId
      }
      const {data} = await reqListMerchandiseByAnchorId(param)
      // console.log(data)
      this.setData({
        goods:data
      })
    },

    navigateToMerchandiseDetail(e){
      const id = e.currentTarget.dataset.productid
      //type为 4 表示该商品是从直播下的订单
      const type = 4
      const anchorId = this.data.anchorId
      wx.navigateTo({
        url: `/pages/good/good?productId=${id}&businessType=${type}&ReferenceId=${anchorId}`,
      })
    },

    handleConfirm(e){
      
      this.triggerEvent("send",e.detail.value)
      this.setData({
        value:""
      })
    }
  }
})